﻿
namespace App.Domain.Handlers {
    using System;
    using App.Data;
    using App.Domain.Contracts;

    public class DeleteCompany {
        private readonly ICompanyRepository _companyRepository;

        public DeleteCompany(ICompanyRepository companyRepository) {
            _companyRepository = companyRepository;
        }

        public virtual void Execute(Guid companyId) {
            var companyToDelete = _companyRepository.GetCompany(companyId);

            if (companyToDelete != null) {
                _companyRepository.Delete(companyId);
            }
            else {
                throw new BusinessServicesException("UnableToDeleteVehicleExceptionMessage");
            }
        }
    }
}
